<?php

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\I18N;
use Illuminate\Support\Collection;

/**
 * @var int              $limit_high
 * @var int              $limit_low
 * @var Collection<Fact> $tasks
 */

?>

<table
    class="table table-bordered table-sm wt-table-tasks datatables d-none"
    <?= view('lists/datatables-attributes') ?>
    <?php if ($tasks->count() < e($limit_high)) : ?>
        data-paging="false"
    <?php endif ?>
    data-filter="false"
    data-info="false"
    data-length-change="false"
    data-page-length="<?= e($limit_low) ?>"
>
    <thead>
        <tr>
            <th class="d-none d-md-table-cell wt-side-block-optional">
                <?= I18N::translate('Date') ?>
            </th>
            <th>
                <?= I18N::translate('Record') ?>
            </th>
            <th class="d-none d-md-table-cell wt-side-block-optional">
                <?= I18N::translate('Username') ?>
            </th>
            <th>
                <?= I18N::translate('Research task') ?>
            </th>
        </tr>
    </thead>

    <tbody>
        <?php foreach ($tasks as $task) : ?>
            <tr>
                <td data-sort="<?= $task->date()->julianDay() ?>" class="d-none d-md-table-cell wt-side-block-optional">
                    <?= $task->date()->display() ?>
                </td>
                <td data-sort="<?= e($task->record()->sortName()) ?>">
                    <a href="<?= e($task->record()->url()) ?>">
                        <?= $task->record()->fullName() ?>
                    </a>
                </td>
                <td class="d-none d-md-table-cell wt-side-block-optional">
                    <?= e($task->attribute('_WT_USER')) ?>
                </td>
                <td dir="auto">
                    <?= e($task->value()) ?>
                </td>
            </tr>
        <?php endforeach ?>
    </tbody>
</table>
